package com.core.framework.db.jdbc.support.dialect;

import com.core.framework.db.DBStatic;
/**
 * 用于解决 因数据库种类不同所产生的不同的SQL语句
 * @author 刘涛
 * @since Jul 2, 2012
 */
public class SqlDialectFactory implements DBStatic{

	public static AbstractDialect createSQLdialect(){
		AbstractDialect sQLdialect = null;
		String dbType = p.getProperty("jdbc.dbtype");
		try {
			if(dbType.equals("mysql"))
			{
				sQLdialect = (AbstractDialect) Class.forName(MYSQL).newInstance();
			}
			else if(dbType.equals("oracle"))
			{
				sQLdialect = (AbstractDialect) Class.forName(ORACLE).newInstance();
			}
			else if(dbType.equals("sqlserver2005"))
			{
				sQLdialect = (AbstractDialect) Class.forName(SQLSERVER05).newInstance();
			}
			else if(dbType.equals("sqlserver2008"))
			{
				sQLdialect = (AbstractDialect) Class.forName(SQLSERVER08).newInstance();
			}
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		return sQLdialect;
	}
	
	
	public static void main(String[] args){
//		AbstractDialect d = SqlDialectFactory.createSQLdialect();
//		Page<User> page = new Page<User>();
//		page.setOrderby(" createTime ");
//		d.getPageSQL(page, "SS_User",null );
//		d.getPageCountSQL("SS_User", null );
	}
	
}
